//
//  NSError+RDelivery.h
//  RDelivery
//
//  Created by selmerzhang on 2021/8/19.
//  Copyright © 2021 Tencent. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, RDeliveryErrorCode) {
    RDeliveryErrorNone = 0,  //无错误
    RDeliveryErrorHttpRequestException = 1,   //HTTP请求错误
    RDeliveryErrorHttpErrorStatusCode = 2,  //HTTP状态码错误
    RDeliveryErrorHttpErrorOther = 3,  //其他HTTP错误
    RDeliveryErrorServerError = 10,         //后台返回了错误码
    RDeliveryErrorPackError = 20,          //组包失败
    RDeliveryErrorParseError = 21,         //解包失败
    RDeliveryErrorDecodeError = 22,        //解密失败
    RDeliveryErrorEncryptPackParseError = 23,  //加密包解包失败
    RDeliveryErrorRespUnzipError = 24,     //解压失败
    RDeliveryErrorEncryptError = 25,       //加密失败
    RDeliveryErrorEnvChanged = 30,         //已切换环境，丢弃包
    RDeliveryErrorGuidChanged = 31,        //已切换guid，丢弃包
    RDeliveryErrorPullLimit = 32,          //拉取被限频
    RDeliveryErrorBatchRequestFail = 40,   //聚合请求拉取失败
    RDeliveryErrorGetRequestFail = 60,          // get请求拉取失败,网络失败
    RDeliveryErrorGetResponseDecryptFail = 70,  // get请求回包解密失败
    RDeliveryErrorGetResponseDecodeFail = 80,   // get请求回包解码失败
    RDeliveryErrorOther = 90,              //其他错误
    RDeliveryErrorAddExpUserQRCodeEmpty = 100,  //扫码添加体验人员，二维码ID为空
    RDeliveryErrorAddExpUserEnvIdEmpty = 101,  //扫码添加体验人员，envID为空
};

static NSString * _Nonnull const RDeliveryClientErrorDomain = @"RDeliveryClientErrorDomain";
static NSString * _Nonnull const RDeliveryServerErrorDomain = @"RDeliveryServerErrorDomain";

NS_ASSUME_NONNULL_BEGIN

@interface NSError (RDelivery)

/// RDelivery SDK相关错误信息
/// @param code 错误码
/// @param description 错误描述
+ (instancetype)rd_clientErrorWithCode:(RDeliveryErrorCode)code description:(nullable NSString*)description;

/// RDelivery 后台相关错误信息
/// @param code 错误码
/// @param description 错误描述
+ (instancetype)rd_serverErrorWithCode:(RDeliveryErrorCode)code description:(nullable NSString*)description;

@end

NS_ASSUME_NONNULL_END
